package com.ckjw.gobang.utils;


import com.ckjw.gobang.view.ChessBroad;

/**
 * 将鼠标点击的坐标转换为数组索引下标工具类
 * @author lck and djw
 * @Date 2022年6月6日-下午7:41:49
 */
public class Coordinate {
	/**
     * 将行转换为Y坐标
     */
    public static int rowToY(int row) {
        return ChessBroad.chessSize * (row - 1) + ChessBroad.chessSize / 2;
    }

    /**
     * 将列转换为X坐标
     */
    public static int colToX(int col) {
    	return (col-1)*ChessBroad.chessSize+ChessBroad.chessSize / 2+10;
    }

    /**
     * Y坐标转换为行
     */
    public static int yToRow(int y) {
        return (y + ChessBroad.chessSize) / ChessBroad.chessSize;
    }

    /**
     * 将X坐标转换为行列
     */
    public static int xToCol(int x) {
    	 return (x-10)/ChessBroad.chessSize + 1;
    }

}
